﻿var FY0 = "┏━━━━━━━━━━━┓";
var FY1 = "┃       079MAX4       ┃";
var FY2 = "┃ 脚本仿制  　定制脚本 ┃";
var FY3 = "┃ 技术支持 　 游戏顾问 ┃";
var FY4 = "┃ ＷＺ添加　  地图制作 ┃";
var FY5 = "┃ 售登陆器    售下载器 ┃";
var FY6 = "┣━━━━━━━━━━━┫";
var FY7 = "┃唯一QQ: 782772124┃";
var FY8 = "┗━━━━━━━━━━━┛";
var FY9 = "怀旧岛单机交流群免费分享";

var 红色箭头 = "#fUI/UIWindow/Quest/icon6/7#";
var 正方箭头 = "#fUI/Basic/BtHide3/mouseOver/0#";
var status = 0;

var 随机数量上限 = 10;
var itemList1 = [
//物品id，几率，数字越大概率越大，数量
[4011000, 1, 1, 1],
[4011001, 1, 1, 1],
[4011002, 1, 1, 1],
[4011003, 1, 1, 1],
[4011004, 1, 1, 1],
[4011005, 1, 1, 1],
[4011006, 1, 1, 1],
[4011007, 1, 1, 1],
[4021000, 1, 1, 1],
[4021001, 1, 1, 1],
[4021002, 1, 1, 1],
[4021003, 1, 1, 1],
[4021004, 1, 1, 1],
[4021005, 1, 1, 1],
[4021006, 1, 1, 1],
[4021007, 1, 1, 1],
[4021008, 1, 1, 1]
];

var useNx = 10000000;
var sel0 = -1;
function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) 
{
	if(FY9 == "怀旧岛单机交流群免费分享" && FY7 == "┃唯一QQ: 782772124┃")
	{
		if (status == 0 && mode == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
		{
			status++;
		} else {
			status--;
		}

		if (status == 0) {
			var txt = "#d你可以从高级矿石宝箱里随机获得以下物品#n#k\r\n";
			txt += "#d每次开启将随机获得1-10个成品矿石\r\n";
			txt += "#d#L1##b"+红色箭头+" 打开箱子#l\r\n\r\n";
			txt += "\t#b"+正方箭头+" 奖品展示： \r\n";
			
			var txt2 = "";
			for (var i = 0; i < itemList1.length;  i++){
				txt2 += "#i"+itemList1[i][0]+":#";
			}
			cm.sendSimple(txt + txt2);
		} else if (status == 1) {
			var jobid=cm.getPlayer().getJob();
			sel0 = selection;
			cm.sendGetNumber(""+正方箭头+"#d 请输入开启次数\r\n"
			+"#d每次开启箱子需要消耗1把#r#t4000435##d和1个#r高级矿石宝箱\r\n#r联盟钥匙和高级矿石宝箱#d可以通过怪物掉落/日常/活动等渠道获得",
			1, 1, 99999
			);
		} else if(status == 2) {
			if (!cm.checkNumSpace(0, selection)) {
				cm.sendOk("背包空间不足"+selection+"格");
				cm.dispose();
				return;
			}
			switch (sel0) {
				case 1:
					if (!cm.haveItem(4031096,1*selection)) 
					{
						cm.sendOk("#v4031095#数量不足#r "+(1*selection)+" #k，无法开启");
						cm.dispose();
						return;
					} 
					else 
					{
						if(!cm.haveItem(4031096,1*selection))
						{
							cm.sendOk("#v4031096#数量不足#r "+(1*selection)+" #k，无法开启");
							cm.dispose();
							return;
						}
						else
						{
							cm.gainItem(4031096, -(1*selection));
							
						}
					}
					break;
				case 2:
					if (cm.getMeso() < (useNx*selection)) {
						cm.sendOk("金币不足"+(useNx*selection)+"，无法抽奖");
						cm.dispose();
						return;
					} else {
						cm.gainMeso(-useNx*selection);
					}
					break;
				default:
					cm.sendOk("脚本出错，请联系管理员");
					cm.dispose();
					return;
			}
			var txt = "恭喜你获得道具：\r\n";
			for (var i = 0; i < selection; i++) {
				var item;
				var sjsl = Math.floor(Math.random()*随机数量上限)
				var ran = Math.floor(Math.random() * 100);
				var ran1 = null;
				ran1 = finalGift(itemList1);
				if(cm.getBossRankCount("屏蔽"+ran1[0]) > 0){
					cm.gainGachaponItem2(4001126, 1, "秘密箱子", ran1[3]);
				}
				else
				{
					cm.gainItem(ran1[0],sjsl);
					cm.喇叭(1,"玩家"+cm.getPlayer().getName()+"从高级矿石宝箱里开出了"+sjsl+"个成品矿石");
				}
				cm.gainItem(4000313, 1);
				txt += "#v" + ran1[0] + "#\r\n";
			}
			cm.dispose();
			return;
		}
	}
	else
	{
			cm.sendOk("请勿更改版权信息,否则脚本将无法正常使用");
			cm.dispose();
	}
}

function finalGift(lists) {
	var maxChance = 0;
	for (var i in lists) {
		if (lists[i][1] > maxChance) {
			maxChance = lists[i][1];
		}
	}
	var chance = Math.floor(Math.random() * maxChance);
	var finalitem = Array();
	for (var i = 0; i < lists.length; i++) {
		if (lists[i][1] >= chance) {
			finalitem.push(lists[i]);
		}
	}
	var ran1 = Math.floor(Math.random() * finalitem.length);
	return finalitem[ran1];
}